package com.tracy.lifeproject.discovery.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;
import com.tracy.lifeproject.R;
import com.tracy.lifeproject.bean.BuyerRecordBean;
import com.tracy.lifeproject.discovery.goods.adapter.BuyerRecordAdapter;
import com.tracy.lifeproject.utils.CircleImageView;

import java.util.List;

/**
 * Created by ZJS on 2016/7/24.
 */
public class BuyerRecyclerAdapter extends RecyclerView.Adapter<BuyerRecyclerAdapter.MyBuyerRecyclerViewHolder> {

    private Context mContext;
    private List<BuyerRecordBean.DataBean.FavoriteListsBean.ItemsInfoBean> mDatas;

    public BuyerRecyclerAdapter(Context context,List<BuyerRecordBean.DataBean.FavoriteListsBean.ItemsInfoBean> datas){
        this.mContext = context;
        this.mDatas = datas;
    }

    @Override
    public MyBuyerRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_buyer_inner_imgs,parent,false);
        return new MyBuyerRecyclerViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MyBuyerRecyclerViewHolder holder, int position) {
        Picasso.with(mContext).load(mDatas.get(position).getCover_image_url()).into(holder.circleImageView);
    }

    @Override
    public int getItemCount() {
        return mDatas==null?0:mDatas.size();
    }

    public class MyBuyerRecyclerViewHolder extends RecyclerView.ViewHolder{
        private CircleImageView circleImageView;
        public MyBuyerRecyclerViewHolder(View itemView) {
            super(itemView);
            circleImageView = (CircleImageView) itemView.findViewById(R.id.img_buyerIcon);
        }
    }
}
